Skip to content

fix: Escapes in raw text #29

Open
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/xss-noscript
Open

fix: Escapes in raw text #29
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/xss-noscript

Conversation

@SkyZeroZx
Copy link
Copy Markdown

@SkyZeroZx SkyZeroZx commented May 23, 2026

fix: Escapes </noscript in raw text when scripting enabled

Ensuring raw text within <noscript> elements is properly escaped during serialization if scripting is enabled. Adds a test to verify controlled payloads cannot break out of <noscript> and inject scripts.

Fixes angular/angular#68903

fix: fix raw-text element serialization

Correct raw-text closing-tag escaping so astral Unicode characters cannot
misalign the escaped < character. This prevents serialized raw-text content
from breaking out into executable markup such as </iframe><script>.

Prevents XSS by ensuring raw text within `<noscript>` elements is properly escaped during serialization if scripting is enabled.
Adds a test to verify controlled payloads cannot break out of `<noscript>` and inject scripts.

Fixes angular/angular#68903
@alan-agius4 alan-agius4 self-requested a review May 24, 2026 07:34
Correct raw-text closing-tag escaping so astral Unicode characters cannot
misalign the escaped `<` character. This prevents serialized raw-text content
from breaking out into executable markup such as `</iframe><script>`.
Comment thread lib/NodeUtils.js
// (`[...rawText]`). Astral characters (e.g. emoji) before the match
// would otherwise shift the replacement and leave a real `</tag>`
// break-out in the output.
return rawText.replace(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was doing some regression testing and also found this issue with iframe and TextContent using astral characters like '😀', so we'll fix it in the same PR; it's added as another commit.

@SkyZeroZx SkyZeroZx changed the title fix: Escapes </noscript in raw text when scripting enabled fix: Escapes in raw text May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<noscript> text serialization in Angular SSR

1 participant